package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.system.domain.Finance;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectProgressView;
import com.ruoyi.system.service.IProjectProgressViewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 *
 * @author ruoyi
 * @date 2024-04-27
 */
@RestController
@RequestMapping("/system/progressView")
public class ProjectProgressViewController extends BaseController
{
    @Autowired
    private IProjectProgressViewService projectProgressViewService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectProgressView projectProgressView)
    {
        startPage();
        List<ProjectProgressView> list = projectProgressViewService.selectProjectProgressViewList(projectProgressView);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectProgressView projectProgressView)
    {
        List<ProjectProgressView> list = projectProgressViewService.selectProjectProgressViewList(projectProgressView);
        ExcelUtil<ProjectProgressView> util = new ExcelUtil<ProjectProgressView>(ProjectProgressView.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    @Anonymous
    @GetMapping("/charts")
    public List<ProjectProgressView> charts()
    {
        return projectProgressViewService.selectProjectProgressViewList(new ProjectProgressView());
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:query')")
    @GetMapping(value = "/{progressId}")
    public AjaxResult getInfo(@PathVariable("progressId") Long progressId)
    {
        return success(projectProgressViewService.selectProjectProgressViewByProgressId(progressId));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectProgressView projectProgressView)
    {
        return toAjax(projectProgressViewService.insertProjectProgressView(projectProgressView));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectProgressView projectProgressView)
    {
        return toAjax(projectProgressViewService.updateProjectProgressView(projectProgressView));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:progressView:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{progressIds}")
    public AjaxResult remove(@PathVariable Long[] progressIds)
    {
        return toAjax(projectProgressViewService.deleteProjectProgressViewByProgressIds(progressIds));
    }
}
